function Task(dts){    
	HBox.apply(this,[]);
	this.htmlX.addClass("Task");
	if(dts.idRequest){
		this.uid = dts.idRequest;
	}
	dts = $.extend({"idRequest":this.uid,"t":this.uid,"onLoad":function(dtk2){}}, dts);
	
	this.idRequest = dts.idRequest;
	this.t = dts.t;
	this.onLoad = dts.onLoad;
	this.service = new String(dts.s);	
	this.htmlX.attr("id","uid_"+this.uid);	
	this.htmlX.css({"width":"100%"});
	this.htmlX[0]["dta"] = this;
	
	this.lbMsg = new Label(this.service.replace("."," ").toUpperCase()+" #"+this.idRequest);
	this.lbMsg.htmlX.css({"float":"left","margin-bottom":"2px","width":"100%"});
	this.imgReload = new Img("http://underas.googlecode.com/svn/web/lib/org/underas/assets/img16x16/terminatedlaunch_obj.gif");
	this.imgReload.htmlX.css({"float":"right","margin-top":"2px"});
	this.pbTask = new ProgressBar(0);
    //this.pbTask.setLabel("task:"+this.idRequest+"-"+this.t+" s:"+this.service.replace("."," ").toUpperCase());
	this.pbTask.setBarColor("#639718");
	this.pbTask.htmlX.css({"width":"95%","float":"left"});
	this.imgReload.htmlX.click($.proxy(this.reload,this));
	this.appendChildX(this.lbMsg);	
	this.appendChildX(this.pbTask);	
	this.appendChildX(this.imgReload);	
}

 Task.prototype.finalizar = function(dtk2){
	this.pbTask.setProgress(100);
	this.htmlX.addClass("finalizado");	
	this.imgReload.htmlX.attr("src","http://underas.googlecode.com/svn/web/lib/org/underas/assets/img16x16/change-iconp.png");	
	this.onLoad(dtk2);	
	rm.refresh();
 };

 Task.prototype.reload = function(){	
	if(this.htmlX.hasClass("inErro")){
		//retry
		this.pbTask.setProgress(20);
	}else if(!this.htmlX.hasClass("finalizado")){
		this.cancel();
	}
	
 };
 
  Task.prototype.cancel = function(){
	this.pbTask.setBarColor("#D6D2CA");	
	this.htmlX.addClass("finalizado");	
	rm.refresh();
 };
 
 Task.prototype.setErro = function(eh){
	 if(eh){
		//this.lbMsg.setText("erro");
		this.pbTask.setBarColor("#E18542");
                this.htmlX.addClass("terro");
	 }else{	
		//this.lbMsg.setText("reajustado");
                this.htmlX.removeClass("terro");
		this.pbTask.setBarColor("#639718");	
	 }
 };
 Task.prototype.setMSG=function(strMSG){
		//var textoT = new String(this.getTaskDesc()+" "+strMSG);
		//this.lbMsg.htmlX.attr("alt",textoT);
		//alert('msgproccess:::\n'+strMSG+'\ntoprocess:::\n'+textoT);
		this.lbMsg.setText(this.getTaskDesc()+":"+strMSG);
 };	
 
 
 Task.prototype.setTaskDesc=function(strMSG){
		var textoT = new String(this.getTaskDesc()+" "+strMSG);
		//this.pbl.setToolTip(textoT);
		if(textoT.length>55){
			textoT=textoT.substr(0,55)+"...";
		}
		this.setMSG(textoT);
};	

Task.prototype.getTaskDesc = function(){
	var servis = new String(this.service);
	servis=servis.replace("."," ").toUpperCase();
	return servis;
};

Task.prototype.erroState=function(msge){
	this.pbTask.setProgress(50);
	
	this.setErro(true);		
	this.setMSG(msge);	
};	
